package com.graduation.mybatis.bean;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.List;

@Data
@NoArgsConstructor
@AllArgsConstructor
public class NutritionSummary {
    private Double totalCalories = 0.0;
    private Double totalProtein = 0.0;
    private Double totalFat = 0.0;
    private Double totalCarbohydrate = 0.0;

    public void merge(NutritionSummary other) {
        this.totalCalories += other.getTotalCalories();
        this.totalProtein += other.getTotalProtein();
        this.totalFat += other.getTotalFat();
        this.totalCarbohydrate += other.getTotalCarbohydrate();
    }

    // 添加增量计算方法
    public void addValues(Double calories, Double protein,
                          Double fat, Double carbohydrate) {
        this.totalCalories += calories;
        this.totalProtein += protein;
        this.totalFat += fat;
        this.totalCarbohydrate += carbohydrate;
    }
}